const currentEnvironment = import.meta.env.MODE;
console.log("yaojunhao import.meta.env.MODE", currentEnvironment);
// 判断是否是开发环境 显示接口地址
let isShowApiAddress = false;
if (currentEnvironment == "production") {
  console.log("yaojunhao currentEnvironment_当前是生产环境");
}
if (currentEnvironment == "development") {
  isShowApiAddress = true;
  console.log("yaojunhao currentEnvironment_当前是开发环境");
}
// api接口地址 设置生产环境只有服务器这个一个选项，如果有多个，虽然不显示在页面，但是还是可以在本地进行设置
const allApiAddressObj = isShowApiAddress
  ? {
      ZB: "http://192.168.0.141:8081",
      ZB001: "http://192.168.2.101:8081",
      ZB002: "http://192.168.2.22:8081",
      JJH: "http://192.168.0.100:8081",
      JJH001: "http://192.168.2.12:8081",
      JJH002: "http://192.168.2.20:8081",
      FuWuQi: "http://154.221.19.51",
      bengdi: "http://localhost:8081",
      aaa: "http://192.168.2.54:8081",
      bbb: "http://192.168.2.61:8081",
      beirun: "http://172.16.1.39:8081",
    }
  : {
      FuWuQi: "http://154.221.19.51",
      // FuWuQi: "http://192.168.2.54:8081",
    };
// 要在一开始就设置
function nowApiAddressFun() {
  let defaultKey = localStorage.getItem("nowApiAddressObjKey") || "FuWuQi";
  setNowApiAddressObj(defaultKey);
  return allApiAddressObj[defaultKey];
}
// 设置默认接口地址
let nowApiAddressObj = nowApiAddressFun();

// 设置接口
function setNowApiAddressObj(data) {
  localStorage.setItem("nowApiAddressObjKey", data);
}

export {
  nowApiAddressObj,
  setNowApiAddressObj,
  allApiAddressObj,
  isShowApiAddress,
};
